package org.cicd.utils

/**###################################################

 定义获取 常规shell  命令#

#####################################################*/


/**
 * 复制文件 目录
 *
 * @param source
 * @param destination
 * @return
 */
def cp(source, destination) {
    def util = new utils();
    if(util.isWindows()) {
        return " copy ${source} ${destination} /Y"
    } else {
        return " cp ${source} ${destination}"
    }
}

/**
 * 获取当前目录 路径
 * @return
 */
def pwd() {
    def util = new utils();
    if(util.isWindows()) {
        return " chdir"
    } else {
       return  " pwd "
    }
}

/**
 * 删除文件
 *
 * @param sourceFile
 * @return
 */
def delFile(sourceFile) {
    def util = new utils();
    if(util.isWindows()) {
        return " del ${sourceFile}"
    } else {
       return  " rm -r ${sourceFile} "
    }
}

/**
 * 删除文件夹
 *
 * @param sourceFolder
 * @return
 */
def delFolder(sourceFolder) {
    def util = new utils();
    if(util.isWindows()) {
        return " rmdir /S /Q ${sourceFolder}"
    } else {
       return  " rm -rf ${sourceFolder} "
    }
}


def zip(zipName, targetFolder) {
    def util = new utils();
    if(util.isWindows()) {
        " zip  -rq ${zipName}   ${targetFolder}"
    } else {
       return  " zip  -rq ${zipName}   ${targetFolder}"
    }
}

def unzip(zipFile, targetFolder) {
    def util = new utils();
    if(util.isWindows()) {
        " unzip -o  ${zipFile}  -d  ${targetFolder}"
    } else {
        return  " unzip -o ${zipName}  -d ${targetFolder}"
    }
}
